<template>
    <div class="title">指令(Directive)</div>
    <div class="unitBar">
        <span>v-html</span>
    </div>
    <div class="vhtml inner">
        <div>{{ htmlStrDemo }}</div>
    </div>
    <div class="vhtml inner">
        <div v-html="htmlStrDemo"></div>
    </div>
    <div></div>
    <hr>
    <div class="unitBar">
        <span>v-if/ v-else-if /v-else</span>
    </div>
    <div class="unitBar">
        <span class="vif inner" v-if="numflag === 1">第1个span标签</span>
        <span class="vif inner" v-else-if="numflag === 2">第2个span标签</span>
        <span class="vif inner" v-else>第1个span标签</span>
    </div>
    <hr>
    <div class="unitBar">
        <span>v-show</span>
    </div>
    <div class="unitBar">
        <span class="inner" v-show="numflag === 1">v-show span标签 会被渲染</span>
    </div>
    <hr>
    <div class="unitBar">
        <span>v-once</span>
    </div>
    <div class="inner vonce">
        <span>{{ numonce }}</span>
        <span v-once>{{ numonce }}</span>
        <button @click="addNumonce">numonce++</button>
    </div>
</template>
<script>
export default {
    name: 'Directive',
    data() {
        return {
            htmlStrDemo: "<img src='/pic/1.jpg' style='height:240px'>",
            numflag: 1,
            numonce: 100,
        }
    },
    methods: {
        addNumonce() {
            this.numonce++;
        }
    }
}
</script>
<style scoped>


.vhtml {
    /* float: left; */
    width: 400px;
    height: 240px;
    border: 1px solid #f1f1f1;
    margin: 0 10px 10px 40px;
}

.vif {
    display: block;
}

hr {
    border: 0;
}

.vonce>span {
    padding: 0 5px;
}
</style>